
class Dashboard::OrdersController < Dashboard::BaseController
  before_action :set_order, only: [:show]
  before_action :require_logined

  def index
    basic_query = Order.where("1=1")
    basic_query = basic_query.where(workflow_state: params[:state]) if params[:state]
    @orders = basic_query.where(user_id: current_user.id).paginate(page: params[:page] || 1, per_page: params[:per_page] || 10).order(updated_at: :desc, workflow_state: :desc)
  end

  def show
    @order_histories = @order.order_histories
  end

  private

  def set_order
    @order = Order.find(params[:id])
  end

end
